/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package canteen.sys.model.entity.repository;

import canteen.sys.model.entity.Feedback;
import canteen.sys.model.generic.GenericHibernateDAOSupport;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author TNT
 */
public class FeedbackDAOImpl extends GenericHibernateDAOSupport<Feedback, Long> implements FeedbackDAO {

    @Override
    public List<Feedback> findAllByUserId(int userId, boolean status) {
        List<Feedback> listFeedback = null;
        Transaction transaction = getSession().beginTransaction();
        try {
            listFeedback = getSession().createCriteria(Feedback.class)
                    .add(Restrictions.eq("loginMaster.lId", userId))
                    .add(Restrictions.eq("status", status)).list();
            transaction.commit();
        } catch (HibernateException ex) {
            transaction.rollback();
        }
        return listFeedback;
    }
}
